from flask import Flask, render_template
from pic import map_i, map_m, stackb, bar1, bar2, line_m, line_f, scatter, liquid, pie_c,mul_pie

app = Flask(__name__)


@app.route('/')
def index():
    """ 首页 """
    title = '全球癌症数据可视化分析'
    return render_template(
        'index.html',
        the_title=title
    )


@app.route('/today', methods=['GET', 'POST'])
def today():
    """ 今日概况页面 """
    title = '今日概况'
    m1 = map_i()
    m2 = map_m()
    sta_b = stackb()
    bar_f = bar1()
    bar_m = bar2()

    return render_template(
        'today.html',
        the_title=title,
        map1_charts=m1.render_embed(),
        map2_charts=m2.render_embed(),
        bar_charts=sta_b.render_embed(),
        bar1_charts=bar_f.render_embed(),
        bar2_charts=bar_m.render_embed()
    )


@app.route('/overtime', methods=['GET', 'POST'])
def overtime():
    """ 过往调查页面 """
    title = '过往调查'
    l1 = line_m()
    l2 = line_f()

    return render_template(
        'overtime.html',
        the_title=title,
        l1_charts=l1.render_embed(),
        l2_charts=l2.render_embed()
    )


@app.route('/future')
def future():
    """ 未来分析页面 """
    title = '未来分析'
    s = scatter()
    liq = liquid()

    return render_template(
        'future.html',
        the_title=title,
        s_charts=s.render_embed(),
        liq_charts=liq.render_embed()
    )


@app.route('/causes')
def causes():
    """ 病因追查页面 """
    title = '病因追查'
    pie1 = pie_c()
    pie2 = mul_pie()

    return render_template(
        'causes.html',
        the_title=title,
        pie1_charts=pie1.render_embed(),
        pie2_charts=pie2.render_embed()
    )


if __name__ == '__main__':
    app.run()
